<?php
if (!defined('IN_SYS')) {
    header('HTTP/1.1 403 Forbidden');
    exit(0);
}

/** 
* 随机数类
* 
* 产生一些随机数(串) 
* @author xzqiapchu(www.xzzhangqiaochu.top)
* @version v1.0.0.200128_beta
*/
class Random
{
    /**
    * 获取16进制随机串
    * 
    * 保证第一位不为0
    * 
    * @param int $len 长度
    * @return string 生成的随机串
    */
    static function getHex($len)
    {
        $raw = '0123456789abcdef';
        $rand_hex = substr($raw, rand(1, 15), 1);
        for ($i = 1; $i <= $len - 1; $i++)
            $rand_hex .= substr($raw, rand(0, 15), 1);
        return $rand_hex;
    }
}
